package org.blogwu.learn.threadLearn.volatile深入;

public class Hello {
    static volatile Demo demo = new Demo();


    static class Thread1 extends Thread {

        @Override
        public void run() {
            while (demo.isBb()) ;
            System.out.println("Thread over");
        }
    }

    public static void main(String[] args) {
        Thread1 t1 = new Thread1();
        t1.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("set false");
        demo.setBb(false);
        System.out.println("set false over");
    }
}
